<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script>
	window.onload = function() {
		var oDiv = document.getElementById("div1");

		var sMystyle = "color";
		var sValue = "red";

		oDiv.style[sMystyle] = sValue;

	}
	</script>
</head>
<body>
	<div id="div1">这是一个div元素</div>
</body>
</html>